package com.clkj.aimin.dao.topic;

import com.clkj.aimin.pojo.topic.Topic;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * @author yawang
 * @create 2024/04/02 18:14:15
 **/
@Repository
public interface TopicMapper extends Mapper<Topic> {

    @Select("select  a.*,b.doctor_name,b.doctor_pic from (select *,row_number() over(partition by topic_type order by topic_type) as rownum  from t_cl_topic ) " +
            "as a  left join t_cl_doctor b on a.doctor_id = b.doctor_id where rownum<4 and topic_status = 1  order by zhiding desc,order_num asc " )
    List<Topic> listTopicAndVideos();

    @Select("select * from (select *,row_number() over(partition by topic_type order by topic_type) as rownum  from t_cl_topic " +
            "where doctor_id = #{doctorId}) "+
            " as t_cl_topic where rownum<4  order by zhiding desc,order_num asc ")
    List<Topic> listTopic(@Param("doctorId") Integer doctorId);


    @Select("<script> " +
            "select a.*,b.doctor_name,b.doctor_pic from t_cl_topic a left join t_cl_doctor b " +
            "on a.doctor_id = b.inuserId where a.topic_type = #{topicType} and topic_status = 1  " +
            "<if test='doctorId!=0'> and a.doctor_id = #{doctorId} </if>" +
            "</script>")
    List<Topic> listTopicByDoctorId(Integer doctorId,Integer topicType);
}
